CC = gcc
CFLAGS = -Wall -Wextra -std=c99 -O2
LDLIBS = -lm
TARGET = exif_writer
SOURCE = exif_writer.c
API_OBJ = exif_api.o
API_SOURCES = exif_api.c
EXAMPLE_TARGET = example
EXAMPLE_SOURCES = example.c $(API_OBJ)

all: $(TARGET) $(EXAMPLE_TARGET)

$(TARGET): $(SOURCE)
	$(CC) $(CFLAGS) -o $(TARGET) $(SOURCE) $(LDLIBS)

$(API_OBJ): $(API_SOURCES) exif_writer.h
	$(CC) $(CFLAGS) -c -o $(API_OBJ) $(API_SOURCES)

$(EXAMPLE_TARGET): $(EXAMPLE_SOURCES) exif_writer.h
	$(CC) $(CFLAGS) -o $(EXAMPLE_TARGET) example.c $(API_OBJ) $(LDLIBS)

clean:
	rm -f $(TARGET) $(EXAMPLE_TARGET) $(API_OBJ)

test: $(TARGET)
	./$(TARGET) 20250724_153209_731.jpg output.jpg "Canon" "EOS 5D Mark IV" 39.9042 116.4074 100

test_api: $(EXAMPLE_TARGET)
	./$(EXAMPLE_TARGET)

.PHONY: all clean test test_api 